<template>
  <div id="app">
    <div class="xpnav_div" :class="{xpnav_div2:switcherT==1}">
      <a href="#"><img v-show="switcherT==0" @click="routerClick('navhome',0)" class="home_login"
                       src="../images/home_log.png"></a>
      <a href="#"><img v-show="switcherT==1" @click="routerClick('navhome',0)" class="home_login"
                       src="../images/home_log2.png"></a>
      <div class="xpnav_con">
        <a href="#" v-for="(item,index) in routerData" @click="routerClick(item.router,index)"><span
          class="xpnav_con_span xpnav_color" :class="{xpnav_color2:switcherT==1,xpnav_con_span2:index==num}">{{item.name}}</span></a>
        <!--{xpnav_con_span2:index==num}-->
      </div>
      <div class="home_phone">
        <img class="home_pimg" src="../images/home_phone.png">
        <span class="home_pspan xpnav_color" :class="{xpnav_color2:switcherT==1}">02367236292/18996191805</span>
      </div>
    </div>
    <div class="home_router" :class="{home_router2:switcherT==0}">
      <router-view></router-view>
    </div>
    <!--v-show="!switcherT==0"-->
    <div class="xpbottm">
      <div class="xpbottm_left">
        <img class="xpbottm_log" src="../images/home_log.png">
        <!--<div class="xpbottm_con">Copyright ©2017</div>-->
        <div class="xpbottm_con"> 寻朴房科技有限公司</div>
        <a href="http://www.miitbeian.gov.cn/" class="a_hrea">
          <div class="xpbottm_con">渝ICP备18014955号-1</div>
        </a>
      </div>
      <div class="xpbottm_right">
        <div class="xpbottm_right_con">
          <a href="#"><span class="xpbottm_right_con_span" :class="{xpbottm_right_con_span2:numT==0}"
                            @click="routerClick('navmanage',1)">AI资管</span></a>
          <a href="#"><span class="xpbottm_right_con_span" :class="{xpbottm_right_con_span2:numT==1}"
                            @click="routerClick('navhouse',1)">AI家居</span></a>
          <a href="#"><span class="xpbottm_right_con_span" :class="{xpbottm_right_con_span2:numT==2}"
                            @click="routerClick('navtool',1)">AI工具</span></a>
        </div>
        <div class="xpbottm_right_phone">
          <img class="btn_phone" src="../images/home_phone.png">
          <span class="btn_phone_span">全国客服电话:</span>
          <span class="btn_phone_span2">02367236292/18996191805</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        routerData: [
          {
            "router": "navhome",
            "name": "首页"
          },

//          {
//            "router": "navmanage",
//            "name": "AI资管"
//          },
//
//          {
//            "router": "navhouse",
//            "name": "AI家居"
//          },
//
          {
            "router": "navtool",
            "name": "AI工具"
          }, {
            "router": "counselor",
            "name": "咨询师"
          }, {
            "router": "specialhouse",
            "name": "优质房"
          }, {
            "router": "househome",
            "name": "智能家居"
          }, {
            "router": "alliance",
            "name": "异业联盟"
          }, {
            "router": "navabout",
            "name": "关于我们"
          }
        ],
        switcherT: 0,
        num: 0,
        numT: 'NO'
      }
    },
    methods: {
      routerClick: function (router, num) {
        var _this = this;
        _this.num = num;
        if (router == 'navhome') {
          _this.switcherT = 0;
          _this.numT = "No"
        } else if (router == 'navmanage') {
          _this.numT = 0;
          _this.switcherT = 1;
        } else if (router == 'navhouse') {
          _this.numT = 1;
          _this.switcherT = 1;
        } else if (router == 'navtool') {
          _this.numT = 2;
          _this.switcherT = 1;
        } else {
          _this.switcherT = 1;
        }
        localStorage.setItem("xunPuRouter", router);
        localStorage.setItem("xunPuRouterNum", num);
        this.$router.push({
          name: router
        })
      }
    },
    mounted() {
      let _this = this;
      let myRouter = localStorage.getItem("xunPuRouter");
      let myRouterNum = localStorage.getItem("xunPuRouterNum");
      if (!myRouter || !myRouterNum) {
        this.$router.push({
          name: "navhome"
        });
        return
      }
      _this.routerClick(myRouter, myRouterNum)

    }
  }
</script>


